package com.example.nkj.button_editext_toast;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class main extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onButtonClick(View view)
    {
        EditText name=(EditText)findViewById(R.id.editText_name);
        EditText age=(EditText)findViewById(R.id.editText_age);
        switch(view.getId())
        {
            case R.id.button_send:
                Toast.makeText(main.this,"你的名字是："+ name.getText().toString() +"  你的年龄是："+age.getText().toString() , Toast.LENGTH_SHORT).show();
            break;

            case R.id.button_toast:
                Toast.makeText(main.this,"This is a toast" , Toast.LENGTH_SHORT).show();
                name.setText("张三");
                age.setText("35");
            break;
        }
    }
}
